package cn.lkk.samples.lang.fundamental.Operators;

/**
 * Created by lkk on 2015/5/11.
 */
public class DivideByZero {
    public static void main(String[] args) {
        int dividend = 0;

        // 整数除0抛异常
        //int aInt = 5;
        //System.out.println(aInt / dividend);

        // 浮点数除0得到的是NaN或者Infinite
        double aDouble = 5.0;
        boolean isNaN = Double.isInfinite(aDouble / dividend);
        boolean isInfinite = Double.isInfinite(aDouble / dividend);
        String result = "unknown";
        if (isNaN)
            result = "Nan";
        if (isInfinite)
            result = "Infinite";
        System.out.println("浮点数除以0得到的是" + result);

    }
}
